package com.stu.boke.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stu.boke.entity.Menu;
import com.stu.boke.mapper.MenuMapper;
import com.stu.boke.service.MenuService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class MenuServiceImpl implements MenuService{

	@Autowired(required = false)
	private MenuMapper menuMapper;


	@Override
	public List<Menu> listMenu() {
		List<Menu> menuList = null;
        try {
            menuList = menuMapper.listMenu();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("获得所有标签失败, cause:{}", e);
        }
        return menuList;
	}


	@Override
	public Menu insertSubmitMenu(Menu menu) {
		try {
			menuMapper.insert(menu);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("创建分类失败, menu:{}, cause:{}", menu, e);
		}
		return menu;
	}


	@Override
	public void updateMenu(Menu menu) {
		try {
			menuMapper.update(menu);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("更新分类失败, menu:{}, cause:{}", menu, e);
		}
	}

	@Override
	public void deleteMenu(Integer id) {
		try {
			menuMapper.deleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("删除分类失败, menu:{}, cause:{}",  e);
		}
	}


	@Override
	public Menu getMenuById(Integer id) {
		return menuMapper.getMenuById(id);
	}


}
